using RAG.Application.Dtos;
using RAG.Application.Commands; // This using statement is crucial for ApiResult

namespace RAG.Application.Interfaces;

/// <summary>
/// RAG服务接口
/// </summary>
public interface IAppRagService
{
    /// <summary>
    /// 处理文档并生成向量
    /// </summary>
    Task<ApiResult> ProcessDocumentAsync(Guid documentId);
    
    /// <summary>
    /// 检索相关文档块
    /// </summary>
    Task<ApiResult> RetrieveRelevantChunksAsync(string query, Guid? knowledgeBaseId = null, int topK = 5);
    
    /// <summary>
    /// 从所有知识库中检索相关文档块
    /// </summary>
    Task<ApiResult> RetrieveRelevantChunksFromAllKnowledgeBasesAsync(string query, Guid userId, int topK = 5);
    
    /// <summary>
    /// 生成答案
    /// </summary>
    Task<ApiResult> GenerateAnswerAsync(GenerateAnswerDto dto);
    
    /// <summary>
    /// 创建会话
    /// </summary>
    Task<ApiResult> CreateSessionAsync(CreateSessionDto dto);
    
    /// <summary>
    /// 获取会话列表
    /// </summary>
    Task<ApiResult> GetSessionsAsync(Guid userId);
    
    /// <summary>
    /// 获取会话详情
    /// </summary>
    Task<ApiResult> GetSessionAsync(Guid sessionId);
    
    /// <summary>
    /// 更新会话
    /// </summary>
    Task<ApiResult> UpdateSessionAsync(UpdateSessionDto dto);
    
    /// <summary>
    /// 删除会话
    /// </summary>
    Task<ApiResult> DeleteSessionAsync(Guid sessionId, Guid userId);
    
    /// <summary>
    /// 发送消息
    /// </summary>
    Task<ApiResult> SendMessageAsync(SendMessageDto dto);
    
    /// <summary>
    /// 获取会话消息历史
    /// </summary>
    Task<ApiResult> GetSessionMessagesAsync(Guid sessionId);
    
    /// <summary>
    /// 获取问答列表
    /// </summary>
    Task<ApiResult> GetQAListAsync(Guid userId, int page = 1, int pageSize = 10);
    
    /// <summary>
    /// 获取用户对话记录
    /// </summary>
    Task<ApiResult> GetUserConversationsAsync(GetUserConversationsDto dto);
    
    /// <summary>
    /// 调试方法：检查数据库状态
    /// </summary>
    Task<ApiResult> DebugDatabaseStatusAsync();
}
